/*线程的调度*/

class clicker implements Runnable
{
	int click=0;
	Thread t;

	private volatile boolean running = true;
	public clicker(int p)
	{
		t = new Thread(this);
		t.setPriority(p);
	}
	public void run()
	{
		while(running)
		{
			click++;
		}
	} 
	public void stop()
	{
		running = false;
	}
	public void start()
	{
		t.start();
	}
}

public class Thread5
{
	public static void main(String args[])
	{
		Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
		clicker hi = new clicker(Thread.NORM_PRIORITY+2);
		clicker lo = new clicker(Thread.NORM_PRIORITY-2);

		hi.start();
		lo.start();

		try
		{
			Thread.sleep(10000);
		}
		catch(Exception e)
		{
			System.out.println("The main thread have exception");
		}

		lo.stop();
		hi.stop();
		try
		{
			hi.t.join();
			lo.t.join();
		}
		catch(Exception e)
		{
			System.out.println("Exception");
		}

		System.out.println("low Thread:"+lo.click);
		System.out.println("high Thread:"+hi.click);
	}
}
